/**
 * 模拟栈的构造函数，后进先出结构
 * Last In First Out
 * 就像放一堆书，后放的在上面，拿走的时候从最上面开始拿
 */

function Stack() {
  var items = []; // 一个数组，用来存放栈数据

  this.push = function(element){
    items.push(element);
  }

  this.pop = function(){
    return items.pop();
  }

  this.peek = function(){
    return items[items.length - 1];
  }

  this.isEmpty = function(){
    return items.length === 0;
  }

  this.clear = function(){
    items = [];
  }

  this.size = function(){
    return items.length;
  }
}